import Vue from 'vue'
import Router from 'vue-router'

Vue.use(Router)

/* Layout */
import Layout from '@/layout'

/* Router Modules */
import componentsRouter from './modules/components'
import chartsRouter from './modules/charts'
import tableRouter from './modules/table'
import nestedRouter from './modules/nested'
import axios from 'axios';
import * as path from "path";

/**
 * Note: sub-menu only appear when route children.length >= 1
 * Detail see: https://panjiachen.github.io/vue-element-admin-site/guide/essentials/router-and-nav.html
 *
 * hidden: true                   if set true, item will not show in the sidebar(default is false)
 * alwaysShow: true               if set true, will always show the root menu
 *                                if not set alwaysShow, when item has more than one children route,
 *                                it will becomes nested mode, otherwise not show the root menu
 * redirect: noRedirect           if set noRedirect will no redirect in the breadcrumb
 * name:'router-name'             the name is used by <keep-alive> (must set!!!)
 * meta : {
    roles: ['admin','editor']    control the page roles (you can set multiple roles)
    title: 'title'               the name show in sidebar and breadcrumb (recommend set)
    icon: 'svg-name'/'el-icon-x' the icon show in the sidebar
    noCache: true                if set true, the page will no be cached(default is false)
    affix: true                  if set true, the tag will affix in the tags-view
    breadcrumb: false            if set false, the item will hidden in breadcrumb(default is true)
    activeMenu: '/example/list'  if set path, the sidebar will highlight the path you set
  }
 */

/**
 * constantRoutes
 * a base page that does not have permission requirements
 * all roles can be accessed
 */

export const constantRoutes = [

  {
    path: '/login',
    component: () => import('@/views/login/index'),
    hidden: true
  },
 /* {
    path: '/registered',
    component: () => import('@/views/wish/systemManagement/registered'),
    hidden: true
  },*/
  {
    path: '/auth-redirect',
    component: () => import('@/views/login/auth-redirect'),
    hidden: true
  },
  {
    path: '/404',
    component: () => import('@/views/error-page/404'),
    hidden: true
  },
  {
    path: '/401',
    component: () => import('@/views/error-page/401'),
    hidden: true
  },
  {
    path: '/',
    component: Layout,
    redirect: '/hello',
    children: [
      {
        path: '/hello',
        component: () => import('@/views/wish/hello/hello'),
        name: 'hello',
      }
    ]
  },
    // {
    //   path: '/',
    //   component: Layout,
    //   redirect: '/',
    //   meta: {
    //     title: '系统管理',
    //     icon: 'el-icon-s-help'
    //   },
    //   children: [
    //     {
    //       path: '/modules/sys/role',
    //       component: () => import('@/views/wish/systemManagement/role'),
    //       name: 'roleList',
    //       meta: { title: '角色管理', icon: 'el-icon-user-solid', affix: true }
    //     },
    //     {
    //       path: '/modules/sys/user',
    //       component: () => import('@/views/wish/systemManagement/user'),
    //       name: 'userList',
    //       meta: { title: '用户管理', icon: 'el-icon-user', affix: true }
    //     },
    //     {
    //       path: '/modules/sys/menu',
    //       component: () => import('@/views/wish/systemManagement/menu'),
    //       name: 'userList',
    //       meta: { title: '菜单管理', icon: 'el-icon-menu', affix: true }
    //     },
    //     {
    //       path: '/modules/sys/dept',
    //       component: () => import('@/views/wish/systemManagement/dept'),
    //       name: 'deptList',
    //       meta: { title: '部门管理', icon: 'el-icon-s-cooperation\n', affix: true }
    //     },
    //     {
    //       //http://localhost:8095/druid/login.html
    //       path: '/modules/sys/sqlMonitor',
    //       component: () => import('@/views/wish/systemManagement/druid'),
    //       name: 'sqlMonitor',
    //       meta: { title: 'SQL监控', icon: 'el-icon-video-camera', affix: true },
    //     },
    //     {
    //       path: '/modules/sys/business',
    //       component: () => import('@/views/wish/systemManagement/business'),
    //       name: 'business',
    //       meta: { title: '商户管理', icon: 'el-icon-s-shop', affix: true },
    //     },
    //     {
    //       path: '/modules/sys/log',
    //       component: () => import('@/views/wish/systemManagement/log'),
    //       name: 'index.vue',
    //       meta: { title: '日志管理', icon: 'dashboard', affix: true }
    //     },
    //     {
    //       path: '/modules/sys/interface',
    //       component: () => import('@/views/wish/systemManagement/interface'),
    //       name: 'sqlMonitor',
    //       meta: { title: '接口管理', icon: 'el-icon-video-camera', affix: true }
    //     },
    //     {
    //       path: '/modules/sys/esSave',
    //       component: () => import('@/views/wish/systemManagement/esSave'),
    //       name: 'esSave',
    //       meta: { title: 'ES全量同步', icon: 'el-icon-upload', affix: true },
    //     },
    //     {
    //       path: '/modules/sys/icon',
    //       component: () => import('@/views/icons/index'),
    //       name: 'icon',
    //       meta: { title: 'ICON', icon: 'el-icon-info', affix: true },
    //     },
    //   ]
    // }
    // ,
    // {
    //   path: '/house',
    //   component: Layout,
    //   redirect: '/house',
    //   meta: {
    //     title: '房源管理',
    //     icon: 'el-icon-office-building'
    //   },
    //   children: [
    //     {
    //       path: '/modules/sys/roomStatusMap',
    //       component: () => import('@/views/wish/propertyManagement/Cancellationofrent/roomStatusMap.vue'),
    //       name: 'roomStatusMap',
    //       meta: { title: '房态图', icon: 'el-icon-picture-outline-round', affix: true },
    //     },
    //     {
    //       path: '/modules/sys/contract',
    //       component: () => import('@/views/wish/propertyManagement/TenantManagement/contract.vue'),
    //       name: 'contract',
    //       meta: {title: '租客管理', icon: 'el-icon-user-solid', affix: true},
    //     }
    //     ,
    //     {
    //       path: '/modules/sys/inputConcentrated',
    //       component: () => import('@/views/wish/propertyManagement/jizhong/inputConcentrated'),
    //       name: 'inputConcentrated',
    //       meta: { title: '添加集中式房源', icon: 'el-icon-user-solid', affix: true },
    //     },
    //
    //     {
    //       path: '/modules/sys/inputDistributed',
    //       component: () => import('@/views/wish/propertyManagement/fensan/inputDistributed'),
    //       name: 'inputDistributed',
    //       meta: { title: '添加分散式房源', icon: 'el-icon-user-solid', affix: true },
    //       //children:[]
    //     },
    //    /* {
    //       path: '/modules/sys/realEstate',
    //       component: () => import('@/views/wish/propertyManagement/fensan/realEstate/realEstateInput'),
    //       name: 'inputDistributed',
    //       hidden: true,
    //     },*/
    //     {
    //       path: '/modules/sys/contractht',
    //       component: () => import('@/views/wish/propertyManagement/Rentalcontract/contractht.vue'),
    //       name: 'contractht',
    //       meta: { title: '租房合同查询', icon: 'el-icon-s-order', affix: true },
    //     },
    //     {
    //       path: '/modules/sys/contracthtInsert',
    //       component: () => import('@/views/wish/propertyManagement/Rentalcontract/contracthtInsert.vue'),
    //       name: 'contracthtInsert',
    //       meta: { title: '租房合同录入', icon: 'el-icon-tickets', affix: true },
    //     },
    //     {
    //       path: '/modules/sys/contracthtRenew',
    //       component: () => import('@/views/wish/propertyManagement/Rentalcontract/contracthtRenew.vue'),
    //       name: 'contracthtRenew',
    //       meta: { title: '租房合同续约', icon: 'el-icon-document-checked', affix: true },
    //     } ,
    //     {
    //       path: '/modules/sys/contracthtjyInsert',
    //       component: () => import('@/views/wish/propertyManagement/Cancellationofrent/contracthtjyInsert.vue'),
    //       name: 'contracthtjyInsert',
    //       meta: { title: '租房解约合同录入', icon: 'el-icon-document-delete', affix: true },
    //     }
    //     ,
    //     {
    //       path: '/modules/sys/contracthtjy',
    //       component: () => import('@/views/wish/propertyManagement/Cancellationofrent/contracthtjy.vue'),
    //       name: 'contracthtjy',
    //       meta: { title: '租房解约查询', icon: 'el-icon-document', affix: true },
    //     }
    //
    //   ]
    // },{
    //   path: '/shouFang',
    //   component: Layout,
    //   redirect: '/shouFang',
    //   meta: {
    //     title: '收房管理',
    //     icon: 'el-icon-office-building'
    //   },
    //   children: [
    //     {
    //       path: '/modules/sys/housingContractInput',
    //       component: () => import('@/views/wish/housingContractManagement/housingContractInput.vue'),
    //       name: 'housingContractInput',
    //       meta: { title: '收房合同录入', icon: 'el-icon-picture-outline-round', affix: true },
    //     },
    //     {
    //       path: '/modules/sys/housingContractRenew',
    //       component: () => import('@/views/wish/housingContractManagement/housingContractRenew.vue'),
    //       name: 'housingContractRenew',
    //       meta: { title: '收房合同续约', icon: 'el-icon-picture-outline-round', affix: true },
    //     },
    //     {
    //       path: '/modules/sys/housingContractSearch',
    //       component: () => import('@/views/wish/housingContractManagement/housingContractSearch.vue'),
    //       name: 'housingContractSearch',
    //       meta: { title: '收房合同查询', icon: 'el-icon-picture-outline-round', affix: true },
    //     },
    //     {
    //       path: '/modules/sys/terminationAgreementInput',
    //       component: () => import('@/views/wish/housingContractManagement/terminationAgreementInput.vue'),
    //       name: 'terminationAgreementInput',
    //       meta: { title: '解约合同录入', icon: 'el-icon-picture-outline-round', affix: true },
    //     },
    //     {
    //       path: '/modules/sys/terminationAgreementSearch',
    //       component: () => import('@/views/wish/housingContractManagement/terminationAgreementSearch.vue'),
    //       name: 'terminationAgreementSearch',
    //       meta: { title: '解约合同查询', icon: 'el-icon-picture-outline-round', affix: true },
    //     },
    //     {
    //       path: '/modules/sys/ownerManagement',
    //       component: () => import('@/views/wish/housingContractManagement/ownerManagement.vue'),
    //       name: 'ownerManagement',
    //       meta: { title: '业主管理', icon: 'el-icon-picture-outline-round', affix: true },
    //     }
    //   ]
    // },
]

/**
 * asyncRoutes
 * the routes that need to be dynamically loaded based on user roles
 */
export const asyncRoutes = [/*
  {
    path: '/redirect',
    component: Layout,
    hidden: true,
    children: [
      {
        path: '/redirect/:path(.*)',
        component: () => import('@/views/redirect/index')
      }
    ]
  },
  {
    path: '/login',
    component: () => import('@/views/login/index'),
    hidden: true
  },
  {
    path: '/auth-redirect',
    component: () => import('@/views/login/auth-redirect'),
    hidden: true
  },
  {
    path: '/404',
    component: () => import('@/views/error-page/404'),
    hidden: true
  },
  {
    path: '/401',
    component: () => import('@/views/error-page/401'),
    hidden: true
  },
  {
    path: '/',
    component: Layout,
    redirect: '/dashboard',
    children: [
      {
        path: 'dashboard',
        component: () => import('@/views/dashboard/index'),
        name: 'Dashboard',
        meta: { title: 'Dashboard', icon: 'dashboard', affix: true }
      }
    ]
  },
  {
    path: '/documentation',
    component: Layout,
    children: [
      {
        path: 'index',
        component: () => import('@/views/documentation/index'),
        name: 'Documentation',
        meta: { title: 'Documentation', icon: 'documentation', affix: true }
      }
    ]
  },
  {
    path: '/guide',
    component: Layout,
    redirect: '/guide/index',
    children: [
      {
        path: 'index',
        component: () => import('@/views/guide/index'),
        name: 'Guide',
        meta: { title: 'Guide', icon: 'guide', noCache: true }
      }
    ]
  },
  {
    path: '/profile',
    component: Layout,
    redirect: '/profile/index',
    hidden: true,
    children: [
      {
        path: 'index',
        component: () => import('@/views/profile/index'),
        name: 'Profile',
        meta: { title: 'Profile', icon: 'user', noCache: true }
      }
    ]
  }*/
]

const createRouter = () => new Router({
  mode: 'history', // require service support
  scrollBehavior: () => ({ y: 0 }),
  routes: constantRoutes
  //routes:asyncRoutes
})


const router = createRouter()

// Detail see: https://github.com/vuejs/vue-router/issues/1234#issuecomment-357941465
export function resetRouter() {
  const newRouter = createRouter()
  router.matcher = newRouter.matcher
}

export default router
